* ESS 2016 version 2: Model 3

*************************************************************
* Attention: remove missings & prepare labels!
****************************************************************

use ESS8e02, clear

****************************************************************
* prepare data set (official)
****************************************************************
* Missing values (please run this separate do-file first)
 run ESS_miss.do 

* Labels Unicode (please run this separate do-file first)
 run ESS8e02_formats_unicode 

****************************************************************
* prepare data set

numlabel, add

* generate id
gen id=_n

* recode gender female_dummy
recode gndr (1=0)(2=1), gen(female_dummy) 

* church attendance and religiosity
* create rlgatnd_rev
recode rlgatnd (1=7) (2=6) ///
(3=5)(4=4)(5=3)(6=2)(7=1), ///
gen(rlgatnd_rev)

label define label_rlgatnd_rev ///
1"never" 7"daily", replace
label values ///
rlgatnd_rev label_rlgatnd_rev

* labels rlgdgr (Religiosity: self-estimation)
label define label_rlgdgr ///
0"secular" 10"religious", replace
label values ///
rlgdgr label_rlgdgr

* age
summarize agea
* age: centering and age squared
* add curvilinear age effect
* age centering demeaning 
summarize agea, meanonly
gen age_centered = agea-r(mean)
corr agea age_centered
gen age_centered_sq = age_centered^2
corr age_centered age_centered_sq

* education
tab eisced 
mvdecode eisced, mv(55=.e)

/* remove
 create party dummies (ninvoters: missing)
recode prtvtdpl (6=1) (nonmissing=0), gen(pis_dummy)
recode prtvede2 (1 2 3 4 5 7 8 9=0) (6=1), gen(afd_dummy)
recode prtvtcfr (2=1)(nonmissing=0), gen(fn_dummy)
recode prtvtdcz (7=1)(nonmissing=0), gen(usvit_dummy)
recode prtvtdcz (1=1)(nonmissing=0), gen(kscm_dummy)
recode prtvtbat (3=1)(nonmissing=0), gen(fpoe_dummy)
recode prtvtfch (1=1)(nonmissing=0), gen(svp_dummy)
recode prtvtfnl (3=1) (nonmissing=0), gen(pvv_dummy)
recode prtvtbse (10=1) (nonmissing =0), gen(sd_dummy)
recode prtvtdfi (4=1) (nonmissing =0), gen(tf_dummy)
recode prtvtbno (8=1) (nonmissing=0), gen(frp_dummy)
recode prtvtcbe (7=1) (nonmissing=0), gen(vb_dummy)
recode prtvtfee (3=1) (nonmissing=0), gen(irl_dummy)
recode prtvtesi (6=1) (nonmissing=0), gen(sds_dummy)
recode prtvtbit (9=1) (nonmissing=0), gen(ln_dummy) 
recode prtvtehu (1=1) (nonmissing=0), gen(fidesz_dummy)
recode prtvblt1 (5=1) (nonmissing=0), gen(tt_dummy)
recode prtvblt1 (11=1) (nonmissing=0), gen(llra_dummy)
recode prtvtbgb (7=1) (nonmissing=0), gen(ukip_dummy) */

* composite religion index 
* including church attendance and subjective religiosity

* Min-Max transformation of church attendance
recode rlgatnd_rev (1=0) (2=1.67) ///
(3=3.33) (4=5) (5=6.67) (6=8.33) ///
(7=10), gen(rlgatnd_rev_2)
* religion_index (scale 0-10)
egen religion_index = rowmean(rlgdgr rlgatnd_rev_2)
corr rlgdgr rlgatnd_rev_2 religion_index

/* remove create party-dummies for every country

******

tab prtvtdpl, gen(prtvtdpl_) 
tab prtvede2, gen(prtvede2_) 
tab prtvtdcz, gen(prtvtdcz_) 
tab prtvtbat, gen(prtvtbat_)
tab prtvtfch, gen(prtvtfch_)
tab prtvtfnl, gen(prtvtfnl_)
tab prtvtbse, gen(prtvtbse_)
tab prtvtdfi, gen(prtvtdfi_)
tab prtvtbno, gen(prtvtbno_)
tab prtvtcbe, gen(prtvtcbe_)
tab prtvtfee, gen(prtvtfee_)
tab prtvtesi, gen(prtvtesi_)
tab prtvtbit, gen(prtvtbit_)
tab prtvtehu, gen(prtvtehu_)
tab prtvblt1, gen(prtvblt1_)
tab prtvtcfr, gen(prtvtcfr_)
tab prtvtbgb, gen(prtvtbgb_) */

* add christ_dem_mean
* Mean of Christian-Democratic vote in elections since 2001 
* or in last 3 elections (Belgium Flanders)
* since 2006 in CZ & HUN because of electoral alliances in 2002
* use external data set

merge m:1 cntry using Wahlergebnisse_neu_all 

replace christ_dem_mean = 0 if cntry == "FR"
replace christ_dem_mean = 0 if cntry == "GB"
replace christ_dem_mean = 0 if cntry == "HU"
replace christ_dem_mean = 0 if cntry == "PL"
replace christ_dem_mean = 0 if cntry == "EE"
drop _merge

* add epp_mean 
* Mean of EPP vote in last 3 elections 
* or elections since 2001

merge m:1 cntry using Wahlergebnisse_epp_all 

replace epp_mean = 0 if cntry == "GB"

drop _merge


* add populist_dummy
 
 gen populist_dummy = 1 if ///
 prtvtdpl == 6 | prtvtdpl == 2 | prtvede2 == 6 | ///
 prtvtdcz == 7 | ///
prtvtbat == 3 | prtvtfch == 1 | prtvtfnl == 3 | ///
 prtvtbse == 10 | ///
prtvtdfi == 4 | prtvtbno == 8 | prtvtcbe == 7 | ///
 prtvtfee == 6 | ///
prtvtbit == 9 | prtvtbit == 10 | prtvtehu == 1 | ///
 prtvtehu == 2 | ///
prtvtcfr == 2

replace populist_dummy = 0 if ///
populist_dummy ~=1

replace populist_dummy = . if cntry ~= "AT" & ///
 cntry ~="BE" & cntry~="CH" & cntry~="CZ" & ///
 cntry~="DE" & cntry ~="EE" & cntry~="FI" & ///
 cntry~="FR" & cntry ~="HU" & cntry~="IT" & ///
 cntry~="NL" & cntry~="NO" & cntry~="PL" & ///
 cntry~="SE"
 
 replace populist_dummy =. if ///
 cntry=="BE" & lnghom1 ~= "DUT"
 
 gen populist_dummy_uk = populist_dummy
 replace populist_dummy_uk = 1 if ///
 prtvtbgb == 7
 replace populist_dummy_uk = 0 if ///
 populist_dummy_uk ==. & cntry == "GB"
 
 enc cntry, gen(cntry_enc)
 
* Urbanization

tab domicil

recode domicil (1=1)(2/5=0), gen(big_city) 
tab domicil big_city

******************************
* Variable labels
******************************

label variable lrscale "Left-Right"
label variable age_centered "Age (cent.)"
label variable age_centered_sq "Age (cent.) sq"
label variable female_dummy "Female"
label variable hinctnta "Income"
label variable eisced "Education"
label variable big_city "Urban"
label variable rlgatnd_rev "Church Attendance"
label variable christ_dem_mean "Christ-Dem."

* Appendix analysis: anti-immigration attitudes and
* traditionalist attitudes

* Anti-immigration factor

tab1 imsmetn imdfetn impcntr imbgeco imueclt imwbcnt 

factor imsmetn imdfetn impcntr imbgeco imueclt imwbcnt, factors(1)
predict factor_immigration

alpha imsmetn imdfetn impcntr ///
 imbgeco imueclt imwbcnt, item

* Traditionalism factor 
* Conservatism, traditionalism, Men should have more right to job
* attitudes towards Gays and Lesbians
 
tab1 mnrgtjb freehms hmsfmlsh hmsacld

factor mnrgtjb freehms hmsfmlsh hmsacld, factors(1)
predict factor_traditional_gay

alpha mnrgtjb freehms hmsfmlsh hmsacld, item

* Immigration attitudes summary index
* Anti-Immigration
* 0 pro immigrant, 10 anti-immigrant

* Stretching 3 variables from 1-4 to 0-10 scale
* imsmetn imdfetn impcntr

gen imsmetn_2 = 10*((imsmetn-1)/3)
summarize imsmetn imsmetn_2

gen imdfetn_2=10*((imdfetn-1)/3)
summarize imdfetn imdfetn_2

gen impcntr_2=10*((impcntr-1)/3)
summarize impcntr impcntr_2

recode imbgeco (10=0)(9=1)(8=2)(7=3)(6=4)(5=5) ///
(4=6)(3=7)(2=8)(1=9)(0=10), gen(imbgeco_rev) 

recode imueclt (10=0)(9=1)(8=2)(7=3)(6=4)(5=5) ///
(4=6)(3=7)(2=8)(1=9)(0=10), gen(imueclt_rev)

recode imwbcnt (10=0)(9=1)(8=2)(7=3)(6=4)(5=5) ///
(4=6)(3=7)(2=8)(1=9)(0=10), gen(imwbcnt_rev) 

summarize imbgeco imbgeco_rev
summarize imueclt imueclt_rev
summarize imwbcnt imwbcnt_rev

egen index_immigration = rowmean(imsmetn_2 imdfetn_2 impcntr_2 ///
 imbgeco_rev imueclt_rev imwbcnt_rev)
 
summarize index_immigration 

* Moral attitudes summary index
* Traditionalism anti-gay index
* 1 liberal, 5 traditionalist anti-gay

recode mnrgtjb (1=5)(2=4)(3=3)(4=2)(5=1), gen(mnrgtjb_rev) 
recode hmsfmlsh (1=5)(2=4)(3=3)(4=2)(5=1), gen(hmsfmlsh_rev)
summarize mnrgtjb mnrgtjb_rev 
summarize hmsfmlsh hmsfmlsh_rev 

egen index_traditional_gay = rowmean(mnrgtjb_rev freehms hmsfmlsh_rev hmsacld)
summarize index_traditional_gay

save essESS8e02_ready, replace

***************************************************************
* Analysis
***************************************************************

* Figure 1 (revision 19.11.2020) 
* Bar chart church attendance by country
* Starts at minimum 1

* generate new 3-letter country code labels
gen cntry_2 = "AUT" if cntry =="AT"
replace cntry_2 = "CZE" if cntry =="CZ"
replace cntry_2 = "NLD" if cntry =="NL"
replace cntry_2 = "FRA" if cntry=="FR"
replace cntry_2 = "BEL" if cntry=="BE"
replace cntry_2 = "ISL" if cntry=="IS"
replace cntry_2 = "SWE" if cntry=="SE"
replace cntry_2 = "EST" if cntry=="EE"
replace cntry_2 = "NOR" if cntry=="NO"
replace cntry_2 = "GBR" if cntry=="GB"
replace cntry_2 = "DEU" if cntry=="DE"
replace cntry_2 = "FIN" if cntry=="FI"
replace cntry_2 = "HUN" if cntry=="HU"
replace cntry_2 = "ESP" if cntry=="ES"
replace cntry_2 = "CHE" if cntry=="CH"
replace cntry_2 = "RUS" if cntry=="RU"
replace cntry_2 = "AUT" if cntry=="AT"
replace cntry_2 = "SLO" if cntry=="SI"
replace cntry_2 = "ISR" if cntry=="IL"
replace cntry_2 = "POR" if cntry=="PT"
replace cntry_2 = "ITA" if cntry=="IT"
replace cntry_2 = "LIT" if cntry=="LT"
replace cntry_2 = "IRL" if cntry=="IE"
replace cntry_2 = "POL" if cntry=="PL"

graph bar rlgatnd_rev, ///
 over(cntry_2, sort(rlgatnd_rev) label(labsize(small) angle(90))) ///
plotregion(lcolor(black)) exclude0 ylabel(1(1)4, grid) ///
ytitle("Mean church attendance") ///
title("") bar(1, color(gray) lcolor(black)) 
graph export attendance_rev_20200725.png, replace

**********************************************************
* pooled model
* create populist_dummy first, cntry_enc
**********************************************************

**********************************************************
* Pooled Models with UK (revision 19.11.2020): Table 2
**********************************************************

***************************************
* pooled_fe_4: Table 2, Pooled model 1
***************************************

* with big_city (Urbanization 1: big city; 0: everything else)
* church attendance, 
* excluding all non-Christian religions
* & without denomination (missing values)

logit populist_dummy_uk lrscale ///
age_centered age_centered_sq female_dummy ///
 hinctnta eisced big_city c.rlgatnd_rev ///
 i.cntry_enc ///
 [pweight=dweight*pweight] if rlgdnm~=5 & ///
 rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8
 
 estimates store pooled_fe_4

***************************************
* pooled_fe_5: Table 2, Pooled model 2 
*************************************** 
 
 logit populist_dummy_uk lrscale ///
age_centered age_centered_sq female_dummy ///
 hinctnta eisced big_city c.rlgatnd_rev##i.cntry_enc ///
  [pweight=dweight*pweight] if rlgdnm~=5 & ///
 rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8
 
  estimates store pooled_fe_5

* Figure 3
* Western Europe 
 
 margins if cntry~="PL" & ///
 cntry~="HU" & cntry~="CZ" & cntry~="EE", at(rlgatnd_rev=(1(1)7)) over(cntry_enc)

 marginsplot, /// 
recast(line) noci plot1opts(lcolor(blue) lpattern(solid) lwidth(thick)) ///
plot2opts(lcolor(red) lpattern(solid) lwidth(thick)) ///
plot3opts(lcolor(gold) lpattern(solid) lwidth(thick)) ///
 plot4opts(lcolor(orange) lpattern(solid) lwidth(thick)) ///
plot5opts(lcolor(green) lpattern(solid) lwidth(thick)) ///
 plot6opts(lcolor(black) lpattern(solid) lwidth(thick)) ///
plot7opts(lcolor(maroon) lpattern(dash) lwidth(thick))  ///
plot8opts(lcolor(blue) lpattern(dash) lwidth(thick)) ///
plot9opts(lcolor(red) lpattern(dash) lwidth(thick)) ///
plot10opts(lcolor(orange) lpattern(dash) lwidth(thick)) ///
xtitle("Church Attendance") ytitle("Probability") ///
title("") ///
plotregion(margin(large)) ///
legend(order(1 "AUT" 2 "BEL" 3 "CHE" 4 "DEU" ///
5 "FIN" 6 "FRA" 7 "GBR" 8 "ITA" 9 "NLD" 10 "SWE") cols(4)) ///
ylabel(,grid) 

graph save pooled_fe_5_west, replace
graph export pooled_fe_5_west.png, replace

* Figure 4
* East-Central Europe
 
margins if cntry=="PL" | ///
 cntry=="HU" | cntry=="CZ" | cntry=="EE", at(rlgatnd_rev=(1(1)7)) over(cntry_enc)

 marginsplot, /// 
recast(line) noci plot1opts(lcolor(blue) lpattern(solid) lwidth(thick)) ///
plot2opts(lcolor(red) lpattern(solid) lwidth(thick)) ///
plot3opts(lcolor(gold) lpattern(solid) lwidth(thick)) ///
 plot4opts(lcolor(orange) lpattern(solid) lwidth(thick)) ///
xtitle("Church Attendance") ytitle("Probability") ///
title("") ///
plotregion(margin(large)) ///
legend(order(1 "CZE" 2 "EST" 3 "HUN" 4 "POL") rows(2)) ///
ylabel(,grid)

graph save pooled_fe_5_east, replace
graph export pooled_fe_5_east.png, replace


***********************************
* pooled_fe_6: Table 2, Pooled model 3
* Follows the approach by Möhring with christ_dem_mean
*********************************** 
 
 logit populist_dummy_uk lrscale ///
age_centered age_centered_sq female_dummy ///
 hinctnta eisced big_city rlgatnd_rev ///
 c.rlgatnd_rev#c.christ_dem_mean ///
 i.cntry_enc [pweight=dweight*pweight] ///
 if rlgdnm~=5 & ///
 rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8
 
  estimates store pooled_fe_6
  
margins, at(rlgatnd_rev=(1(1)7) christ_dem_mean=(0,15,30))  

* Figure 5 color (in Article)

marginsplot, recast(line) ///
  plot1opts(lcolor(red) lpattern(solid) lwidth(thick)) ///
  plot2opts(lcolor(green) lpattern(solid) lwidth(thick)) ///
  plot3opts(lcolor(blue) lpattern(solid) lwidth(thick)) ///
  ci1opts(lcolor(red)) ci2opts(lcolor(green)) ci3opts(lcolor(blue)) ///
  xtitle("Church Attendance") ytitle("Probability") ///
title("Effect of Church Attendance Depending on" ///
"Vote Share of Christian-Democratic Parties") ///
plotregion(margin(large)) ///
legend(cols(1) order(4 "Christian-Democrats: 0%" ///
5 "Christian-Democrats: 15%" 6 "Christian-Democrats: 30%")) ///
ylabel(,grid)

graph export pooled_fe_6color.png, replace 

* Figure 5 monochrome version (not in Article)

margins, at(rlgatnd_rev=(1(1)7) christ_dem_mean=(0,15,30))  

marginsplot, recast(line) ///
  plot1opts(lcolor(black) lpattern(solid) lwidth(thick)) ///
  plot2opts(lcolor(gs10) lpattern(dash) lwidth(thick)) ///
  plot3opts(lcolor(gs5) lpattern(dash) lwidth(thick)) ///
  ci1opts(lcolor(black)) ci2opts(lcolor(gs10)) ci3opts(lcolor(gs5)) ///
  xtitle("Church Attendance") ytitle("Probability") ///
title("Effect of Church Attendance Depending on" ///
"Vote Share of Christian-Democratic Parties") ///
plotregion(margin(large)) ///
legend(cols(1) order(4 "Christian-Democrats: 0%" ///
5 "Christian-Democrats: 15%" 6 "Christian-Democrats: 30%")) ///
ylabel(,grid)

graph export pooled_fe_6.png, replace 

*

esttab pooled_fe_4 pooled_fe_5 pooled_fe_6 ///
using pooled_fe_uk.tex, replace label not scalars(ll) pr2 ///
se(2) sfmt(2) b(2) obslast ///
star(+ 0.10 * 0.05 ** 0.01 *** 0.001)  

esttab pooled_fe_4 pooled_fe_5 pooled_fe_6 ///
using pooled_fe_uk.rtf, replace label not scalars(ll) pr2 ///
se(2) sfmt(2) b(2) obslast nogaps ///
star(+ 0.10 * 0.05 ** 0.01 *** 0.001)   
 
* Robustness tests: alternative specification of religion

***************************
* pooled_fe_4b: Appendix H, Pooled 4
***************************

* dv: religion_index

logit populist_dummy_uk lrscale ///
age_centered age_centered_sq female_dummy ///
 hinctnta eisced big_city c.religion_index ///
 i.cntry_enc ///
 [pweight=dweight*pweight] if rlgdnm~=5 & ///
 rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8
 
 estimates store pooled_fe_4b

 
***************************
* pooled_fe_5b: Appendix H, Pooled 5
***************************

* dv: religion_index 
 
 logit populist_dummy_uk lrscale ///
age_centered age_centered_sq female_dummy ///
 hinctnta eisced big_city c.religion_index##i.cntry_enc ///
  [pweight=dweight*pweight] if rlgdnm~=5 & ///
 rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8
 
  estimates store pooled_fe_5b
 
 margins if cntry~="PL" & ///
 cntry~="HU" & cntry~="CZ" & cntry~="EE", at(religion_index=(1(1)10)) over(cntry_enc)

 marginsplot, /// 
recast(line) noci plot1opts(lcolor(blue) lpattern(solid) lwidth(thick)) ///
plot2opts(lcolor(red) lpattern(solid) lwidth(thick)) ///
plot3opts(lcolor(gold) lpattern(solid) lwidth(thick)) ///
 plot4opts(lcolor(orange) lpattern(solid) lwidth(thick)) ///
plot5opts(lcolor(green) lpattern(solid) lwidth(thick)) ///
 plot6opts(lcolor(black) lpattern(solid) lwidth(thick)) ///
plot7opts(lcolor(maroon) lpattern(dash) lwidth(thick))  ///
plot8opts(lcolor(blue) lpattern(dash) lwidth(thick)) ///
plot9opts(lcolor(red) lpattern(dash) lwidth(thick)) ///
plot10opts(lcolor(orange) lpattern(dash) lwidth(thick)) ///
xtitle("Religion Index") ytitle("Probability") ///
title("Western Europe: Pooled Model") ///
plotregion(margin(large)) ///
legend(cols(4)) ///
ylabel(,grid) 

graph save pooled_fe_5b_west, replace
graph export pooled_fe_5b_west.png, replace
 
margins if cntry=="PL" | ///
 cntry=="HU" | cntry=="CZ" | cntry=="EE", at(religion_index=(1(1)10)) over(cntry_enc)

 marginsplot, /// 
recast(line) noci plot1opts(lcolor(blue) lpattern(solid) lwidth(thick)) ///
plot2opts(lcolor(red) lpattern(solid) lwidth(thick)) ///
plot3opts(lcolor(gold) lpattern(solid) lwidth(thick)) ///
 plot4opts(lcolor(orange) lpattern(solid) lwidth(thick)) ///
xtitle("Religion Index") ytitle("Probability") ///
title("Central & Eastern Europe: Pooled Model") ///
plotregion(margin(large)) ///
legend(rows(2)) ///
ylabel(,grid)

graph save pooled_fe_5b_east, replace
graph export pooled_fe_5b_east.png, replace

***********************************
* pooled_fe_6b: Appendix H, Pooled 6
* Follows the approach by Möhring with christ_dem_mean
*********************************** 
 
 logit populist_dummy_uk lrscale ///
age_centered age_centered_sq female_dummy ///
 hinctnta eisced big_city religion_index ///
 c.religion_index#c.christ_dem_mean ///
 i.cntry_enc [pweight=dweight*pweight] ///
 if rlgdnm~=5 & ///
 rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8
 
  estimates store pooled_fe_6b
  
margins, at(religion_index=(1(1)10) christ_dem_mean=(0,15,30))  
 
* Color version: Appendix H, Figure 1 
marginsplot, recast(line) ///
  plot1opts(lcolor(red) lpattern(solid) lwidth(thick)) ///
  plot2opts(lcolor(green) lpattern(solid) lwidth(thick)) ///
  plot3opts(lcolor(blue) lpattern(solid) lwidth(thick)) ///
  ci1opts(lcolor(red)) ci2opts(lcolor(green)) ci3opts(lcolor(blue)) ///
  xtitle("Religion Index") ytitle("Probability") ///
title("Effect of Religion Index Depending on" ///
"Vote Share of Christian-Democratic Parties") ///
plotregion(margin(large)) ///
legend(cols(1) order(4 "Christian-Democrats: 0%" ///
5 "Christian-Democrats: 15%" 6 "Christian-Democrats: 30%")) ///
ylabel(,grid)

graph export pooled_fe_6bcolor.png, replace 

*

esttab pooled_fe_4b pooled_fe_5b pooled_fe_6b ///
using pooled_feb_uk.tex, replace label not scalars(ll) pr2 ///
se(2) sfmt(2) b(2) obslast ///
star(+ 0.10 * 0.05 ** 0.01 *** 0.001)  

*********************************************************************
 
***************************************
* Descriptive Statistics and Appendix
***************************************

************************
* EPP parties 6d
************************

***********************************
* pooled_fe_6d: Appendix G, Table 1
* Follows the approach by Möhring with 
* epp_mean instead of christ_dem_mean
*********************************** 
 
 logit populist_dummy_uk lrscale ///
age_centered age_centered_sq female_dummy ///
 hinctnta eisced big_city rlgatnd_rev ///
 c.rlgatnd_rev#c.epp_mean ///
 i.cntry_enc [pweight=dweight*pweight] ///
 if rlgdnm~=5 & ///
 rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8
 
  estimates store pooled_fe_6d
  
margins, at(rlgatnd_rev=(1(1)7) epp_mean=(0,20,40))  
 
* Appendix G, Figure 1
marginsplot, recast(line) ///
  plot1opts(lcolor(red) lpattern(solid) lwidth(thick)) ///
  plot2opts(lcolor(green) lpattern(solid) lwidth(thick)) ///
  plot3opts(lcolor(blue) lpattern(solid) lwidth(thick)) ///
  ci1opts(lcolor(red)) ci2opts(lcolor(green)) ci3opts(lcolor(blue)) ///
  xtitle("Church Attendance") ytitle("Probability") ///
title("Effect of Church Attendance Depending on" ///
"Vote Share of EPP") ///
plotregion(margin(large)) ///
legend(cols(1) order(4 "EPP: 0%" ///
5 "EPP: 20%" 6 "EPP: 40%")) ///
ylabel(,grid)

graph export pooled_fe_6dcolor.png, replace 

*

esttab pooled_fe_6d ///
using pooled_fed_epp.tex, replace label not scalars(ll) pr2 ///
se(2) sfmt(2) b(2) obslast ///
star(+ 0.10 * 0.05 ** 0.01 *** 0.001) 

****************************************************
* Individual level analysis with attitudes as DV
* Moral preference (traditionalism) vs. migration
* 12.10.2020 Factor variable
****************************************************

*************************************************
* negative effect of church attendance
* on anti-immigration attitudes
* the more church attendance, the more positive
* attitude towards immigrants
*************************************************

* Appendix B, Table 2, Model 1 anti-immigration factor model
regress factor_immigration lrscale ///
age_centered age_centered_sq female_dummy ///
 hinctnta eisced big_city rlgatnd_rev ///
  i.cntry_enc [pweight=dweight*pweight] ///
 if populist_dummy_uk~=. &  (rlgdnm~=5 & ///
 rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8)
 
estimates store immigration_factor_model
 
 margins, at(rlgatnd_rev=(1(1)7)) 

* Appendix B, Figure 1
 marginsplot, recast(line) ///
  plot1opts(lcolor(red) lpattern(solid) lwidth(thick)) ///
    ci1opts(lcolor(red)) ///
  xtitle("Church Attendance") ytitle("Anti-Immigration Attitudes") ///
title("Effect of Church Attendance on" ///
"Anti-Immigration Attitudes") ///
plotregion(margin(large)) ///
ylabel(,grid)

graph export immigration_factor.png, replace
 
******************************************************** 
* Higher factor values: less tolerant towards gays and
* and towards female equality
* Positive effect of religion: more religious 
* respondents are less tolerant towards gays and 
* less in favor of female equality
*********************************************************

* Appendix B, Table 2, Model 2, traditionalism factor model
regress factor_traditional_gay lrscale ///
age_centered age_centered_sq female_dummy ///
 hinctnta eisced big_city rlgatnd_rev ///
  i.cntry_enc [pweight=dweight*pweight] ///
 if populist_dummy_uk~=. &  (rlgdnm~=5 & ///
 rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8) 
 
estimates store traditional_factor_model

 margins, at(rlgatnd_rev=(1(1)7)) 
 
 marginsplot, recast(line) ///
  plot1opts(lcolor(red) lpattern(solid) lwidth(thick)) ///
    ci1opts(lcolor(red)) ///
  xtitle("Church Attendance") ytitle("Traditionalist Gender & LGBT Attitudes") ///
title("Effect of Church Attendance on" ///
"Traditionalist Attitudes towards Gender & LGBT") ///
plotregion(margin(large)) ///
ylabel(,grid)

graph export traditional_factor.png, replace

esttab immigration_factor_model traditional_factor_model ///
using immigration_factor_model.tex, replace label not scalars(F) r2 ///
se(2) sfmt(2) b(2) obslast ///
star(+ 0.10 * 0.05 ** 0.01 *** 0.001) 
 
*************************************** 
* Immigration attitudes summary index
* Anti-Immigration
* 0 pro immigrant, 10 anti-immigrant
***************************************
 
***************************************
* Moral attitudes summary index
* Traditionalism anti-gay index
* 1 liberal, 5 traditionalist anti-gay
***************************************

* Appendix B, Table 3
alpha mnrgtjb freehms hmsfmlsh hmsacld, item


************************************* 
* Anti-immigration attitudes  
* 0 pro immigrant, 10 anti-immigrant
* Higher values: against immigrants
*************************************

* Appendix B, Table 4, Model 1
regress index_immigration lrscale ///
age_centered age_centered_sq female_dummy ///
 hinctnta eisced big_city rlgatnd_rev ///
  i.cntry_enc [pweight=dweight*pweight] ///
 if populist_dummy_uk~=. &  (rlgdnm~=5 & ///
 rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8)
 
estimates store immigration_additive_model
 
margins, at(rlgatnd_rev=(1(1)7)) 

* Appendix B, Figure 3
marginsplot, recast(line) ///
  plot1opts(lcolor(red) lpattern(solid) lwidth(thick)) ///
    ci1opts(lcolor(red)) ///
  xtitle("Church Attendance") ytitle("Anti-Immigration Attitudes") ///
title("Effect of Church Attendance on" ///
"Anti-Immigration Attitudes Index") ///
plotregion(margin(large)) ///
ylabel(,grid)

graph export ess_additive_antiimmingrant.png, replace


****************************************************
* Traditionalism, intolerance against gays index
* 1 liberal, 5 traditionalist anti-gay
* Higher values, less tolerant, more traditionalist
****************************************************

* Appendix B, Table 4, Model 2
regress index_traditional_gay lrscale ///
age_centered age_centered_sq female_dummy ///
 hinctnta eisced big_city rlgatnd_rev ///
  i.cntry_enc [pweight=dweight*pweight] ///
 if populist_dummy_uk~=. &  (rlgdnm~=5 & ///
 rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8) 
 
estimates store traditional_additive_model

margins, at(rlgatnd_rev=(1(1)7)) 

* Appendix B, Figure 4
marginsplot, recast(line) ///
  plot1opts(lcolor(red) lpattern(solid) lwidth(thick)) ///
    ci1opts(lcolor(red)) ///
  xtitle("Church Attendance") ytitle("Traditionalist Gender & LGBT Attitudes") ///
title("Effect of Church Attendance on" ///
"Traditionalist Attitudes & anti-LGBT Index") ///
plotregion(margin(large)) ///
ylabel(,grid) 

graph export ess_additive_traditional.png, replace

esttab immigration_additive_model traditional_additive_model ///
using immigration_additive_model.tex, replace label not scalars(F) r2 ///
se(2) sfmt(2) b(2) obslast ///
star(+ 0.10 * 0.05 ** 0.01 *** 0.001) 

***********************************************************************
* Multinomial logit individual country models
***********************************************************************

*=============================================================================== 
* country-specific mlogit estimations, obtain estimates for voting PRR party
* ===============================================================================


* Poland 
	eststo m1: mlogit prtvtdpl lrscale ///
	age_centered age_centered_sq female_dummy ///
	hinctnta eisced big_city rlgatnd_rev ///
	[pweight=dweight] if (rlgdnm~=5 & ///
	rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8) ///
	& prtvtdpl!=9  & prtvtdpl !=7

	margins, at(rlgatnd_rev=(1(1)7)) predict(outcome(6))

	margins , dydx(rlgatnd_rev) predict(outcome(6)) post 			// PiS
	
	esttab m1 using mlogitpoland2.tex, b(2) se(2) not scalars(ll) pr2 nogap unstack label replace 
	

	/*
	Average marginal effects                        Number of obs     =        772
	Model VCE    : Robust

	Expression   : Pr(prtvtdpl==6__Law_and_Justice), predict(outcome(6))
	dy/dx w.r.t. : rlgatnd_rev

	------------------------------------------------------------------------------
				|            Delta-method
				|      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
	-------------+----------------------------------------------------------------
	rlgatnd_rev |   .0634965   .0129582     4.90   0.000     .0380989    .0888941
	------------------------------------------------------------------------------
	*/

	eststo m1: mlogit prtvtdpl lrscale ///
	age_centered age_centered_sq female_dummy ///
	hinctnta eisced big_city rlgatnd_rev ///
	[pweight=dweight] if (rlgdnm~=5 | ///
	rlgdnm~=6 | rlgdnm~=7 | rlgdnm~=8) ///
	& prtvtdpl!=9  & prtvtdpl !=7
	
	margins, at(rlgatnd_rev=(1(1)7)) predict(outcome(2))
	
	margins , dydx(rlgatnd_rev) predict(outcome(2)) post 		    // Kukiz'15
	
	
	/*
	Average marginal effects                        Number of obs     =        772
	Model VCE    : Robust

	Expression   : Pr(prtvtdpl==2__Kukiz_15), predict(outcome(2))
	dy/dx w.r.t. : rlgatnd_rev

	------------------------------------------------------------------------------
				|            Delta-method
				|      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
	-------------+----------------------------------------------------------------
	rlgatnd_rev |   -.019999   .0081266    -2.46   0.014    -.0359269   -.0040711
	------------------------------------------------------------------------------
	*/
		
* Germany

	eststo m1: mlogit prtvede2 lrscale ///
	age_centered age_centered_sq female_dummy ///
	hinctnta eisced big_city rlgatnd_rev ///
	[pweight=dweight] if (rlgdnm~=5 & ///
	rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8) ///
	& prtvede2<=6
	
	margins, at(rlgatnd_rev=(1(1)7)) predict(outcome(6))
	
	margins , dydx(rlgatnd_rev) predict(outcome(6)) post 
	
	esttab m1 using mlogitgermany2.tex, b(2) se(2) not scalars(ll) pr2 nogap unstack label replace 
	
	/* corrected 23.11.2020
	Average marginal effects                        Number of obs     =      1,611
    Model VCE    : Robust

    Expression   : Pr(prtvede2==6__AfD), predict(outcome(6))
    dy/dx w.r.t. : rlgatnd_rev

    ------------------------------------------------------------------------------
                 |            Delta-method
                 |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    rlgatnd_rev |  -.0095426   .0037141    -2.57   0.010    -.0168221    -.002263
    ------------------------------------------------------------------------------
	*/
	

* Czech Republic

	eststo m1: mlogit prtvtdcz lrscale ///
	age_centered age_centered_sq female_dummy ///
	hinctnta eisced big_city rlgatnd_rev ///
	[pweight=dweight] if (rlgdnm~=5 & ///
	rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8)
	
	
	margins , dydx(rlgatnd_rev) predict(outcome(7)) post 
	esttab m1 using mlogitczechia2.tex, b(2) se(2) not scalars(ll) pr2 nogap unstack label replace 
	
	/* corrected 23.11.2020
Average marginal effects                        Number of obs     =        889
Model VCE    : Robust

Expression   : Pr(prtvtdcz==7__Úsvit_přímé_demokracie_Tomia), predict(outcome(7))
dy/dx w.r.t. : rlgatnd_rev

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
 rlgatnd_rev |   .0028154   .0062619     0.45   0.653    -.0094577    .0150886
------------------------------------------------------------------------------
	*/


	
* Austria

	eststo m1: mlogit prtvtbat lrscale ///
	age_centered age_centered_sq female_dummy ///
	hinctnta eisced big_city rlgatnd_rev ///
	[pweight=dweight] if (rlgdnm~=5 & ///
	rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8)	///
	& prtvtbat!=4 & prtvtbat!=6 & prtvtbat!=8 ///
	& prtvtbat!=9 & prtvtbat!=10
	
	margins, at(rlgatnd_rev=(1(1)7)) predict(outcome(3))
	
	margins , dydx(rlgatnd_rev) predict(outcome(3)) post 
	
	esttab m1 using mlogitaustria2.tex, b(2) se(2) not scalars(ll) pr2 nogap unstack label replace 
	
	/* corrected 23.11.2020
Average marginal effects                        Number of obs     =      1,020
Model VCE    : Robust

Expression   : Pr(prtvtbat==3__FPÖ), predict(outcome(3))
dy/dx w.r.t. : rlgatnd_rev

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
 rlgatnd_rev |  -.0344419   .0091701    -3.76   0.000     -.052415   -.0164688
------------------------------------------------------------------------------
	*/
	
	
	
* Switzerland

	eststo m1: mlogit prtvtfch lrscale ///
	age_centered age_centered_sq female_dummy ///
	hinctnta eisced big_city rlgatnd_rev ///
	[pweight=dweight] if (rlgdnm~=5 & ///
	rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8) & ///
	prtvtfch<=7
	
	margins, at(rlgatnd_rev=(1(1)7)) predict(outcome(1))
	
	margins , dydx(rlgatnd_rev) predict(outcome(1)) post 
	
	esttab m1 using mlogitswitzerland2.tex, b(2) se(2) not scalars(ll) pr2 nogap unstack label replace 
	
	/* corrected 23.11.2020
Average marginal effects                        Number of obs     =        566
Model VCE    : Robust

Expression   : Pr(prtvtfch==1__Swiss_People_s_Party), predict(outcome(1))
dy/dx w.r.t. : rlgatnd_rev

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
 rlgatnd_rev |  -.0473373   .0119648    -3.96   0.000    -.0707879   -.0238866
------------------------------------------------------------------------------
	*/
	
	
* Netherlands

	eststo m1: mlogit prtvtfnl lrscale ///
	age_centered age_centered_sq female_dummy ///
	hinctnta eisced big_city rlgatnd_rev ///
	[pweight=dweight] if (rlgdnm~=5 & ///
	rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8)	///
	& prtvtfnl!=9 & prtvtfnl!=11 & prtvtfnl!=16
	
	margins, at(rlgatnd_rev=(1(1)7)) predict(outcome(3))
	
	margins , dydx(rlgatnd_rev) predict(outcome(3)) post 
	
	esttab m1 using mlogitnetherlands2.tex, b(2) se(2) not scalars(ll) pr2 nogap unstack label replace 
		
	/* corrected 23.11.2020
Average marginal effects                        Number of obs     =      1,012
Model VCE    : Robust

Expression   : Pr(prtvtfnl==3__Party_for_Freedom), predict(outcome(3))
dy/dx w.r.t. : rlgatnd_rev

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
 rlgatnd_rev |  -.0224084   .0081675    -2.74   0.006    -.0384165   -.0064004
------------------------------------------------------------------------------
	*/
	

* Sweden

	eststo m1: mlogit prtvtbse lrscale ///
	age_centered age_centered_sq female_dummy ///
	hinctnta eisced big_city rlgatnd_rev ///
	[pweight=dweight] if (rlgdnm~=5 & ///
	rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8) ///
	& prtvtbse!=9 & prtvtbse!=11
	
	margins, at(rlgatnd_rev=(1(1)7)) predict(outcome(10))
	
	margins , dydx(rlgatnd_rev) predict(outcome(10)) post
	
	esttab m1 using mlogitsweden2.tex, b(2) se(2) not scalars(ll) pr2 nogap unstack label replace 
	
	/* corrected 23.11.2020
Average marginal effects                        Number of obs     =      1,147
Model VCE    : Robust

Expression   : Pr(prtvtbse==10__Sverigedemokraterna), predict(outcome(10))
dy/dx w.r.t. : rlgatnd_rev

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
 rlgatnd_rev |  -.0179394   .0081619    -2.20   0.028    -.0339365   -.0019424
------------------------------------------------------------------------------
	*/
	

* Finland

	eststo m1: mlogit prtvtdfi lrscale ///
	age_centered age_centered_sq female_dummy ///
	hinctnta eisced big_city rlgatnd_rev ///
	[pweight=dweight] if (rlgdnm~=5 & ///
	rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8) ///
	& prtvtdfi!=6 & prtvtdfi!=7 & prtvtdfi!=15 ///
	& prtvtdfi!=16
	
	margins , dydx(rlgatnd_rev) predict(outcome(4)) post
	
	esttab m1 using mlogitfinland2.tex, b(2) se(2) not scalars(ll) pr2 nogap unstack label replace 
	
	/* corrected 23.11.2020
Average marginal effects                        Number of obs     =      1,284
Model VCE    : Robust

Expression   : Pr(prtvtdfi==4__True_Finns), predict(outcome(4))
dy/dx w.r.t. : rlgatnd_rev

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
 rlgatnd_rev |  -.0108764   .0099902    -1.09   0.276    -.0304569     .008704
------------------------------------------------------------------------------
	*/
	

* Norway

	eststo m1: mlogit prtvtbno lrscale ///
	age_centered age_centered_sq female_dummy ///
	hinctnta eisced big_city rlgatnd_rev ///
	[pweight=dweight] if (rlgdnm~=5 & ///
	rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8) ///
	& prtvtbno!=9 & prtvtbno!=11
	
	margins , dydx(rlgatnd_rev) predict(outcome(8)) post
	
	esttab m1 using mlogitnorway2.tex, b(2) se(2) not scalars(ll) pr2 nogap unstack label replace 
	
	/* corrected 23.11.2020
Average marginal effects                        Number of obs     =      1,077
Model VCE    : Robust

Expression   : Pr(prtvtbno==8__Progress_Party__FRP_), predict(outcome(8))
dy/dx w.r.t. : rlgatnd_rev

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
 rlgatnd_rev |  -.0024286   .0079005    -0.31   0.759    -.0179133     .013056
------------------------------------------------------------------------------
*/
	

* Belgium

	eststo m1: mlogit prtvtcbe lrscale ///
	age_centered age_centered_sq female_dummy ///
	hinctnta eisced big_city rlgatnd_rev ///
	[pweight=dweight] if (rlgdnm~=5 & ///
	rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8) & lnghom1 == "DUT" ///
	& prtvtcbe!=10 & prtvtcbe!=12 & prtvtcbe!=13 & prtvtcbe!=14 ///
	& prtvtcbe!=4 & prtvtcbe!=16
 
	margins , dydx(rlgatnd_rev) predict(outcome(7)) post
	
	esttab m1 using mlogitbelgium2.tex, b(2) se(2) not scalars(ll) pr2  nogap unstack label replace 
	
	/* corrected 23.11.2020
	Average marginal effects                        Number of obs     =        675
Model VCE    : Robust

Expression   : Pr(prtvtcbe==7__Vlaams_Belang), predict(outcome(7))
dy/dx w.r.t. : rlgatnd_rev

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
 rlgatnd_rev |  -.0011471    .009819    -0.12   0.907    -.0203921    .0180979
------------------------------------------------------------------------------
*/
	
	
	
* Estonia

	eststo m1: mlogit prtvtfee lrscale ///
	age_centered age_centered_sq female_dummy ///
	hinctnta eisced big_city rlgatnd_rev ///
	[pweight=dweight] if (rlgdnm~=5 & ///
	rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8) ///
	& prtvtfee!=5 & prtvtfee!=9 & prtvtfee!=12	
	
	margins , dydx(rlgatnd_rev) predict(outcome(6)) post
	
	esttab m1 using mlogitestonia2.tex, b(2) se(2) not scalars(ll) pr2 nogap unstack label replace 
	
	/* corrected 23.11.2020
Average marginal effects                        Number of obs     =      1,043
Model VCE    : Robust

Expression   : Pr(prtvtfee==_6__Eesti_Konservatiivne_Rahvaer), predict(outcome(6))
dy/dx w.r.t. : rlgatnd_rev

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
 rlgatnd_rev |   .0096804   .0068203     1.42   0.156    -.0036872    .0230479
------------------------------------------------------------------------------
	*/
	

* Italy

numlabel, remove

	eststo m1: mlogit prtvtbit lrscale ///
	age_centered age_centered_sq female_dummy ///
	hinctnta eisced big_city rlgatnd_rev ///
	[pweight=dweight] if (rlgdnm~=5 & ///
	rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8)	///
	& prtvtbit!=3 & prtvtbit!=5 & prtvtbit!=6 ///
	& prtvtbit!=7 & prtvtbit!=11 & prtvtbit!=12 ///
	& prtvtbit!=14
	
	margins , dydx(rlgatnd_rev) predict(outcome(9)) post			// Lega Nord
	
	esttab m1 using mlogititaly2.tex, b(2) se(2) not scalars(ll) pr2 nogap unstack label replace 
	
	/*	
	Average marginal effects                        Number of obs     =        589
	Model VCE    : Robust
	
	Expression   : Pr(prtvtbit==9__Lega_Nord), predict(outcome(9))
	dy/dx w.r.t. : rlgatnd_rev

	------------------------------------------------------------------------------
				|            Delta-method
				|      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
	-------------+----------------------------------------------------------------
	rlgatnd_rev |  -.0087996   .0083907    -1.05   0.294     -.025245    .0076458
	------------------------------------------------------------------------------
	*/
	
	
	mlogit prtvtbit lrscale ///
	age_centered age_centered_sq female_dummy ///
	hinctnta eisced big_city rlgatnd_rev ///
	[pweight=dweight] if (rlgdnm~=5 & ///
	rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8)	///
	& prtvtbit!=3 & prtvtbit!=5 & prtvtbit!=6 ///
	& prtvtbit!=7 & prtvtbit!=11 & prtvtbit!=12 ///
	& prtvtbit!=14
	
	margins , dydx(rlgatnd_rev) predict(outcome(10)) post			// FdI

	/*Average marginal effects                        Number of obs     =        589
	Model VCE    : Robust

	Expression   : Pr(prtvtbit==10__Fratelli_d_Italia), predict(outcome(10))
	dy/dx w.r.t. : rlgatnd_rev

	------------------------------------------------------------------------------
				|            Delta-method
				|      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
	-------------+----------------------------------------------------------------
	rlgatnd_rev |   .0039166   .0052581     0.74   0.456     -.006389    .0142223
	------------------------------------------------------------------------------
	*/
	

* Hungary

numlabel, remove

	eststo m1: mlogit prtvtehu lrscale ///
	age_centered age_centered_sq female_dummy ///
	hinctnta eisced big_city rlgatnd_rev ///
	[pweight=dweight] if (rlgdnm~=5 & ///
	rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8)	///
	& prtvtehu!=5 & prtvtehu!=55
	
	margins, at(rlgatnd_rev=(1(1)7)) predict(outcome(1))
	
	margins , dydx(rlgatnd_rev) predict(outcome(1)) post		// Fidesz
	
	esttab m1 using mlogithungary2.tex, b(2) se(2) not scalars(ll) pr2 nogap unstack label replace 
	
	/* corrected 23.11.2020
Average marginal effects                        Number of obs     =        563
Model VCE    : Robust

Expression   : Pr(prtvtehu==Fidesz___KDNP__Fidesz___Magyar_P), predict(outcome(1))
dy/dx w.r.t. : rlgatnd_rev

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
 rlgatnd_rev |   .0240258   .0138553     1.73   0.083    -.0031302    .0511817
------------------------------------------------------------------------------
*/
	
	eststo m1: mlogit prtvtehu lrscale ///
	age_centered age_centered_sq female_dummy ///
	hinctnta eisced big_city rlgatnd_rev ///
	[pweight=dweight] if (rlgdnm~=5 & ///
	rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8)	///
	& prtvtehu!=5 & prtvtehu!=55
	
	margins , dydx(rlgatnd_rev) predict(outcome(2)) post		// Jobbik
	
	
	/*
Average marginal effects                        Number of obs     =        563
Model VCE    : Robust

Expression   : Pr(prtvtehu==Jobbik__Jobbik_Magyarországért_M), predict(outcome(2))
dy/dx w.r.t. : rlgatnd_rev

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
 rlgatnd_rev |  -.0081062   .0110784    -0.73   0.464    -.0298194     .013607
------------------------------------------------------------------------------
*/

* France

	eststo m1: mlogit prtvtcfr lrscale ///
	age_centered age_centered_sq female_dummy ///
	hinctnta eisced big_city rlgatnd_rev ///
	[pweight=dweight] if (rlgdnm~=5 & ///
	rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8) ///
	& prtvtcfr!=3 & prtvtcfr!=4 & prtvtcfr!=5 ///
	& prtvtcfr!=8 & prtvtcfr!=13 & prtvtcfr!=14 ///
	& prtvtcfr!=15 & prtvtcfr!=16
	
	margins, at(rlgatnd_rev=(1(1)7)) predict(outcome(2))
	
	margins , dydx(rlgatnd_rev) predict(outcome(2)) post
	
	esttab m1 using mlogitfrance2.tex, b(2) se(2) not scalars(ll) pr2 nogap unstack label replace 
	
	/* corrected 23.11.2020
Average marginal effects                        Number of obs     =        856
Model VCE    : Robust

Expression   : Pr(prtvtcfr==FN__Front_National_), predict(outcome(2))
dy/dx w.r.t. : rlgatnd_rev

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
 rlgatnd_rev |  -.0268703   .0118327    -2.27   0.023     -.050062   -.0036785
------------------------------------------------------------------------------
*/
	

* United Kingdom

	eststo m1: mlogit prtvtbgb lrscale ///
	age_centered age_centered_sq female_dummy ///
	hinctnta eisced big_city rlgatnd_rev ///
	[pweight=dweight] if (rlgdnm~=5 & ///
	rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8)	///
	& prtvtbgb<=7 & prtvtbgb!=5
	
	margins, at(rlgatnd_rev=(1(1)7)) predict(outcome(7))
	
	margins , dydx(rlgatnd_rev) predict(outcome(7)) post
	
	esttab m1 using mlogituk2.tex, b(2) se(2) not scalars(ll) pr2 nogap unstack label replace 
	
	/*
Average marginal effects                        Number of obs     =        996
Model VCE    : Robust

Expression   : Pr(prtvtbgb==UK_Independence_Party), predict(outcome(7))
dy/dx w.r.t. : rlgatnd_rev

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
 rlgatnd_rev |  -.0230008   .0094496    -2.43   0.015    -.0415216     -.00448
------------------------------------------------------------------------------
	*/
	
	
	
	/* note that estimates were saved manually in the countryestimates.dta dataset: corrected 23.11.2020 */
	
	use "countryestimates_2.dta", clear	
	
	
	*encode iso, gen(isocode)
	sort est
	gen order = _n
	
	label define order 1 "CHE, SVP" 2 "AUT, FPÖ" 3 "FRA, FN" 4 "GBR, UKIP" 5 "NLD, PVV" ///
	6 "POL, Kukiz'15" 7 "SWE, SD" 8 "FIN, PS" 9 "DEU, AfD" 10 "ITA, Lega" 11 "HUN, Jobbik" 12 "NOR, FRP" 13 "BEL, VB" 14 "CZE, Usvit" 15 "ITA, FdI" ///
	16 "EST, EKRE" 17 "HUN, Fidesz" 18 "POL, PiS"
	
	label values order order  
	
	gen lower90=est-(1.645*se)
	gen upper90=est+(1.645*se)
	
	format est %9.3f

	twoway	rspike upper90 lower90 order, hor ylabel(1(1)18, valuelabel labsize(vsmall)) || rspike upper95 lower95 order, hor ylabel(1(1)18, valuelabel labsize(vsmall)) || scatter order est , mlabel(est) mlabposition(12) legend(off) ///
	xtitle("AME religious attendance") ytitle("") xline(0, lpattern(dash))  ///
	saving(countryeffects.gph, replace)
	
	
	

* =============================================================================== 
* country-specific mlogit estimations, obtain estimates for voting C-dem party
* ===============================================================================	


	use "ESS8e02_ready.dta" , clear
	
* Germany

	mlogit prtvede2 lrscale ///
	age_centered age_centered_sq female_dummy ///
	hinctnta eisced big_city rlgatnd_rev ///
	[pweight=dweight] if (rlgdnm~=5 & ///
	rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8) ///
	& prtvede2<=6
	
	
	margins , dydx(rlgatnd_rev) predict(outcome(1)) post 
	
	/*
	Average marginal effects                        Number of obs     =      1,611
Model VCE    : Robust

Expression   : Pr(prtvede2==CDU_CSU), predict(outcome(1))
dy/dx w.r.t. : rlgatnd_rev

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
 rlgatnd_rev |    .042632   .0086557     4.93   0.000     .0256672    .0595969
------------------------------------------------------------------------------
		
	*/
	

* Czech Republic

	mlogit prtvtdcz lrscale ///
	age_centered age_centered_sq female_dummy ///
	hinctnta eisced big_city rlgatnd_rev ///
	[pweight=dweight] if (rlgdnm~=5 & ///
	rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8)
	
	margins , dydx(rlgatnd_rev) predict(outcome(6)) post 
	
	/*
	Average marginal effects                        Number of obs     =        889
Model VCE    : Robust

Expression   : Pr(prtvtdcz==KDU_ČSL), predict(outcome(6))
dy/dx w.r.t. : rlgatnd_rev

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
 rlgatnd_rev |   .0461521   .0056912     8.11   0.000     .0349976    .0573065
------------------------------------------------------------------------------

	*/
	

	
* Austria
	
	mlogit prtvtbat lrscale ///
	age_centered age_centered_sq female_dummy ///
	hinctnta eisced big_city rlgatnd_rev ///
	[pweight=dweight] if (rlgdnm~=5 & ///
	rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8)	///
	& prtvtbat!=4 & prtvtbat!=6 & prtvtbat!=8 ///
	& prtvtbat!=9 & prtvtbat!=10
	
	margins , dydx(rlgatnd_rev) predict(outcome(2)) post 	
	
	/*
	Average marginal effects                        Number of obs     =      1,020
Model VCE    : Robust

Expression   : Pr(prtvtbat==ÖVP), predict(outcome(2))
dy/dx w.r.t. : rlgatnd_rev

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
 rlgatnd_rev |   .0754153   .0105461     7.15   0.000     .0547454    .0960853
------------------------------------------------------------------------------
		
	*/
	
* Switzerland

	mlogit prtvtfch lrscale ///
	age_centered age_centered_sq female_dummy ///
	hinctnta eisced big_city rlgatnd_rev ///
	[pweight=dweight] if (rlgdnm~=5 & ///
	rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8) & ///
	prtvtfch<=7
	
	margins , dydx(rlgatnd_rev) predict(outcome(4)) post 
	
	/*
	Average marginal effects                        Number of obs     =        566
Model VCE    : Robust

Expression   : Pr(prtvtfch==Christian_Democratic_Party), predict(outcome(4))
dy/dx w.r.t. : rlgatnd_rev

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
 rlgatnd_rev |   .0688859   .0111799     6.16   0.000     .0469738     .090798
------------------------------------------------------------------------------

	*/
	
	
* Netherlands

	mlogit prtvtfnl lrscale ///
	age_centered age_centered_sq female_dummy ///
	hinctnta eisced big_city rlgatnd_rev ///
	[pweight=dweight] if (rlgdnm~=5 & ///
	rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8)	///
	& prtvtfnl!=9 & prtvtfnl!=11 & prtvtfnl!=16
	
	margins , dydx(rlgatnd_rev) predict(outcome(5)) post 
	
	/*
	Average marginal effects                        Number of obs     =      1,012
Model VCE    : Robust

Expression   : Pr(prtvtfnl==Christian_Democratic_Appeal), predict(outcome(5))
dy/dx w.r.t. : rlgatnd_rev

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
 rlgatnd_rev |   .0483756   .0055984     8.64   0.000      .037403    .0593482
------------------------------------------------------------------------------

	*/
	
	
* Sweden

	mlogit prtvtbse lrscale ///
	age_centered age_centered_sq female_dummy ///
	hinctnta eisced big_city rlgatnd_rev ///
	[pweight=dweight] if (rlgdnm~=5 & ///
	rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8) ///
	& prtvtbse!=9 & prtvtbse!=11
	
	margins , dydx(rlgatnd_rev) predict(outcome(3)) post	
	
	/*
	Average marginal effects                        Number of obs     =      1,147
Model VCE    : Robust

Expression   : Pr(prtvtbse==Kristdemokraterna), predict(outcome(3))
dy/dx w.r.t. : rlgatnd_rev

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
 rlgatnd_rev |    .028332   .0041725     6.79   0.000     .0201541    .0365099
------------------------------------------------------------------------------

	*/
	
* Finland

	mlogit prtvtdfi lrscale ///
	age_centered age_centered_sq female_dummy ///
	hinctnta eisced big_city rlgatnd_rev ///
	[pweight=dweight] if (rlgdnm~=5 & ///
	rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8) ///
	& prtvtdfi!=6 & prtvtdfi!=7 & prtvtdfi!=15 ///
	& prtvtdfi!=16
	
	margins , dydx(rlgatnd_rev) predict(outcome(5)) post	
	
	/*
	Average marginal effects                        Number of obs     =      1,284
Model VCE    : Robust

Expression   : Pr(prtvtdfi==Christian_Democrats), predict(outcome(5))
dy/dx w.r.t. : rlgatnd_rev

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
 rlgatnd_rev |   .0363106   .0047832     7.59   0.000     .0269356    .0456855
------------------------------------------------------------------------------

	*/
	
* Norway

	mlogit prtvtbno lrscale ///
	age_centered age_centered_sq female_dummy ///
	hinctnta eisced big_city rlgatnd_rev ///
	[pweight=dweight] if (rlgdnm~=5 & ///
	rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8) ///
	& prtvtbno!=9 & prtvtbno!=11
	
	margins , dydx(rlgatnd_rev) predict(outcome(5)) post	
	
	/*
	Average marginal effects                        Number of obs     =      1,077
Model VCE    : Robust

Expression   : Pr(prtvtbno==Christian_Democratic_Party__KRF_), predict(outcome(5))
dy/dx w.r.t. : rlgatnd_rev

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
 rlgatnd_rev |   .0437551   .0048586     9.01   0.000     .0342323    .0532779
------------------------------------------------------------------------------

	*/
	
* Belgium

	mlogit prtvtcbe lrscale ///
	age_centered age_centered_sq female_dummy ///
	hinctnta eisced big_city rlgatnd_rev ///
	[pweight=dweight] if (rlgdnm~=5 & ///
	rlgdnm~=6 & rlgdnm~=7 & rlgdnm~=8) & lnghom1 == "DUT" ///
	& prtvtcbe!=10 & prtvtcbe!=12 & prtvtcbe!=13 & prtvtcbe!=14 ///
	& prtvtcbe!=4 & prtvtcbe!=16
 
	margins , dydx(rlgatnd_rev) predict(outcome(2)) post	
	
	/*
	Average marginal effects                        Number of obs     =        675
Model VCE    : Robust

Expression   : Pr(prtvtcbe==CD_V), predict(outcome(2))
dy/dx w.r.t. : rlgatnd_rev

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
 rlgatnd_rev |   .0659646   .0113784     5.80   0.000     .0436633    .0882659
------------------------------------------------------------------------------

	*/
	
	
	
	/* note that estimates were saved manually in the countryestimates.dta dataset */
	
	use "countryestimates-cdem_3.dta", clear	
	
	*encode iso, gen(isocode)
	sort est
	gen order = _n
	
	label define order 1 "SWE, KD"  2 "FIN, KD" 3 "DEU, CDU/CSU" 4 "NOR, KrF" 5 "CZE, KDU-ČSL" 6 "NLD, CDA" 7 "BEL, CD&V" 8 "CHE, CVP" 9 "AUT, ÖVP"
	
	label values order order  
	
	gen lower90=est-(1.645*se)
	gen upper90=est+(1.645*se)
	
	format est %9.3f

	twoway	rspike upper95 lower95 order , hor ylabel(1(1)9, valuelabel labsize(small))  || rspike upper90 lower90 order , hor ylabel(1(1)9, valuelabel labsize(small))  || scatter order est , mlabel(est) mlabposition(12) legend(off) ///
	xlabel(-.02(.02).08) xtitle("AME religious attendance") ytitle("") xline(0, lpattern(dash))  ///
	saving(countryeffectscdem-revision.gph, replace)

	
***********************************************************
* The end replication file
***********************************************************
	
	
	
	
	











